-------------------------------------------------------------------------------
-- RTSAI - Real-Time Strategy engine for AI research
-- Copyright(C) 2006 DIMAp-UFRN, licensed under LGPL
--
-- RTSAI state machine for the seeker in the capture-the-flag example
-------------------------------------------------------------------------------
log = false
State {
    -- STATE ATTRIBUTES -------------------------------------------------------
    name = "seeking_the_flag",

    -- STATE FUNCTIONS --------------------------------------------------------

    act = function ( self )
        local seek = self.unit:steerForSeek ( target )
        local enemy = game.players.attacker:get_unit(1)
        local steer = self.unit:steerForEvasion ( enemy )
        local wander = self.unit:steerForWander(100)
        log_vector ("wander=", wander)
        action.move.steer = seek
        return action.move
    end,


    -- EVENT CALLBACKS --------------------------------------------------------

    on_flag_captured = function ( self, event )
        print ("Woohooooo!!!!!  I got it!")
    end,


    on_seeker_captured = function ( self, event )
        print ("Oops!!!")
    end
}
